#!/usr/bin/env python
# coding=utf-8
# @Time    : 2021/12/26
# @Author  : 秋天的落寞

import re
from loguru import logger


def Device_config(conn):
    """
    发送配置命令
    :param conn: Login_device函数的 connect
    :return:
    """
    try:
        output = conn.send_config_from_file(config_file="command_list.txt")
        print(output)
        # res = con.send_command("dis vlan")  # 打印发送1条配置
        # logger.info(res)
        save = conn.save_config()  # 保存配置
        if re.findall(r"successfully", save, re.I | re.M):
            print("配置保存成功")
        else:
            logger.error("配置保存失败，请登陆设备确认是否保存！")
    except Exception as f:
        logger.error(f)
